import config from '@/config/defaultSettings'
const colorList = [
  {
    key: '拂晓蓝（默认）',
    color: '#1677ff',
    hover: 'rgba(22, 119, 255, 0.8)'
  },
  {
    key: '薄暮',
    color: '#F5222D',
    hover: 'rgba(245, 34, 45, 0.8)'
  },
  {
    key: '火山',
    color: '#FA541C',
    hover: 'rgba(250, 84, 28, 0.8)'
  },
  {
    key: '日暮',
    color: '#FAAD14',
    hover: 'rgba(250, 173, 20, 0.8)'
  },
  {
    key: '明青',
    color: '#13C2C2',
    hover: 'rgba(19, 194, 194, 0.8)'
  },
  {
    key: '极光绿',
    color: '#52C41A',
    hover: 'rgba(81, 195, 25, 0.8)'
  },
  {
    key: '极客蓝',
    color: '#2F54EB',
    hover: 'rgba(46, 82, 231, 0.8)'
  },
  {
    key: '酱紫',
    color: '#722ED1',
    hover: 'rgba(114, 46, 209, 0.8)'
  }
]

const updateDarkMode = (isDark) => {
  let styleTag = document.getElementById('themeCss')
  const appTag = document.getElementById('html')
  if (!styleTag) {
    styleTag = document.createElement('link')
    styleTag.setAttribute('id', 'themeCss')
    document.head.appendChild(styleTag)
  }
  if (isDark) {
    styleTag.setAttribute('href', '/themes/dark.css')
    appTag!.className = 'darkMode'
  } else {
    styleTag.setAttribute('href', '')
    appTag!.className = ''
  }
}

const updateColorWeak = (isColorWeak) => {
  const app = document.getElementById('html')
  isColorWeak ? app!.classList.add('colorWeak') : app!.classList.remove('colorWeak')
}

const updateGrayMode = (isGrayMode) => {
  const app = document.getElementById('html')
  isGrayMode ? app!.classList.add('grayMode') : app!.classList.remove('grayMode')
}

export { colorList, updateColorWeak, updateGrayMode, updateDarkMode }
